home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Magazine 28 Bonus
/
CDRomMagazine-SoftKey-ArtPassion-FrenchVersion-Win31Mac.bin
/
data
/
cngrkpl.dir
/
00120_Script_GAME HANDLERS
< prev
next >
Wrap
Text File
|
1996-05-30
|
8KB
|
250 lines
-- ---------------------------------------------------------------
-- Handler goldenSectionInPlace returns true if the user placed the
-- outline in a proper place and false otherwise.
on goldenSectionInPlace
global outline, goldenSectionInfo, sectionName, sectionRect
set markerName = the frameLabel
repeat with i = 1 to the number of lines in goldenSectionInfo
set lineInfo = line i of goldenSectionInfo
set sectionName = item 1 of lineInfo
if goldenSectionPlaced(sectionName) then
returnOutlineToPlace
else -- an outline was not placed around the piece
setSectionRect(lineInfo)
if (markerName = item 2 of lineInfo) and (inside(point(the mouseH,the mouseV), sectionRect)) then
return TRUE
end if
end if
end repeat
end
-- ---------------------------------------------------------------
-- Handler doMatchGoldenSection
on doMatchGoldenSection
global currentPlacedPiece, sectionName, sectionRect
-- place the piece on the board
putOutlineAroundPiece(sectionName)
-- set the castNum of sprite currentPlacedPiece = the number of cast (sectionName && "GoldenSection")
-- spriteBox currentPlacedPiece, rectLeft(sectionRect), rectTop(sectionRect), rectRight(sectionRect), rectBottom(sectionRect)
returnOutlineToPlace
updateStage
updateCurrentPlacedPiece
updatePlacedGoldenSectionsList(sectionName)
updateFramePlacedPieces(sectionName)
updateScore
end
-- ---------------------------------------------------------------
-- Handler returnOutlineToPlace
on returnOutlineToPlace
global outline, outlineH, outlineV
set the locH of sprite outline = outlineH
set the locV of sprite outline = outlineV
end
-- -----------------------------------------------------------
-- Handler updatePlacedGoldenSectionsList adds the just placed
-- outline to the global variable placedGoldenSectionsList.
on updatePlacedGoldenSectionsList whichSection
global placedGoldenSectionsList
add(placedGoldenSectionsList, whichSection)
end
-- -----------------------------------------------------------
-- Handler goldenSectionPlaced returns true if the given piece
-- was already placed and false otherwise
on goldenSectionPlaced sectionName
global placedGoldenSectionsList
return getPos(placedGoldenSectionsList, sectionName)
end
-- ---------------------------------------------------------------
-- Handler dragOutline
on dragOutline whichPiece, checkHandler, matchHandler
-- if they clicked on whichPiece (checked by the sprite number of the clickOn)
if (the clickOn = whichPiece) then
flashLightBulbs
if placedASection() then fadeLastPlacedSection
TrackAndCheck(whichPiece, checkHandler, matchHandler)
end if
end
-- ---------------------------------------------------------------
-- Handler placedASection returns TRUE if the user found a golden
-- section already and FALSE otherwise.
on placedASection
global placedGoldenSectionsList
return count(placedGoldenSectionsList)
end
-- ---------------------------------------------------------------
-- Handler fadeLastPlacedSections sets the color of the last placed
-- outline to fade a bit and not confuse the screen.
on fadeLastPlacedSection
global currentPlacedPiece
set the foreColor of sprite (currentPlacedPiece-1) to 80 -- last placed piece
end
-- ---------------------------------------------------------------
-- Handler flashLightBulbs flashes the lightbulbs when the user
-- clicks on the outline.
on flashLightBulbs
global rightBulb, leftBulb
-- The bulbs flash one at a time:
-- First the right
flashOneBulb(rightBulb)
repeat with i = 1 to 6
-- now the right and left will alternate
flashOneBulb(rightBulb)
flashOneBulb(leftBulb)
end repeat
-- Finally, return the right to original
flashOneBulb(rightBulb)
end
-- ---------------------------------------------------------------
-- Handler flashOneBulb
on flashOneBulb whichBulb
set bulbCastName = the name of cast the castNum of sprite whichBulb
set bulbStatus = value(word 2 of bulbCastName)
set newBulbCast = word 1 of bulbCastName && string(not(bulbStatus))
set the castNum of sprite whichBulb = the number of cast newBulbCast
updateStage
end
-- ---------------------------------------------------------------
-- Handler goNextGSGameFrame goes to the next frame in the game
on goNextGSGameFrame whichFrame
-- remove the outlines of the last frame
global currentPlacedPiece, firstPlacedOutline, GSFrame1PlacedList
global GSFrame2PlacedList, goldenSectionInfo
repeat with i = firstPlacedOutline to currentPlacedPiece
removeFromStage(i)
end repeat
updateStage
-- reInitialize currentPlacedPiece
initializeCurrentPlacedPiece
-- put back the placed outlines of the new frame
set placedList = value("GSFrame" & whichFrame & "PlacedList")
repeat with i = 1 to count(placedList)
set sectionName = getAt(placedList,i)
repeat with j = 1 to the number of lines in goldenSectionInfo
if (sectionName = item 1 of line j of goldenSectionInfo) then
-- place that piece on stage
setSectionRect(line j of goldenSectionInfo)
putOutlineAroundPiece(sectionName)
updateCurrentPlacedPiece
exit repeat -- replace next piece
end if
end repeat
end repeat
end
on updateFramePlacedPieces sectionName
global GSFrame2PlacedList, GSFrame1PlacedList
if (the frameLabel = "GS1") then
add(GSFrame1PlacedList, sectionName)
else if (the frameLabel = "GS2") then
add(GSFrame2PlacedList, sectionName)
end if
end
-- ---------------------------------------------------------------
-- Handler initializeCurrentPlacedPiece sets the global varibale
-- currentPlacedPiece to the value of the global variable
-- firstPlacedOutline.
on initializeCurrentPlacedPiece
global currentPlacedPiece, firstPlacedOutline
set currentPlacedPiece = firstPlacedOutline
end
-- ---------------------------------------------------------------
-- Handler setSectionRect sets the global variable sectionRect to
-- the rect of the piece in the given line of data.
on setSectionRect lineInfo
global sectionRect
set sectionLeft = value(word 1 of item 3 of lineInfo)
set sectionTop = value(word 2 of item 3 of lineInfo)
set sectionRight = value(word 3 of item 3 of lineInfo)
set sectionBottom = value(word 4 of item 3 of lineInfo)
set sectionRect = rect(sectionLeft, sectionTop, sectionRight, sectionBottom)
end
-- ---------------------------------------------------------------
-- Handler putOutlineAroundPiece
on putOutlineAroundPiece sectionName
global currentPlacedPiece, sectionRect
set the castNum of sprite currentPlacedPiece = the number of cast (sectionName && "GoldenSection")
spriteBox currentPlacedPiece, rectLeft(sectionRect), rectTop(sectionRect), rectRight(sectionRect), rectBottom(sectionRect)
end
-- ---------------------------------------------------------------
-- Handler updateScore updates the score whenever an outline has
-- been correctly placed around something with a golden section.
on updateScore
set currentScore = value(the text of field "score")
set currentScore = currentScore + 1
put currentScore into field "score"
if currentScore = 19 then success
end
-- ---------------------------------------------------------------
-- Handler playNarration plays the given narration. If the narration is
-- an external soundFile it _has_ to have extension ".AIF" it uses sound playfile.
-- command Otherwise it assumes it is an imported castmember and uses "puppetSound"
on playNarration aNarration
global soundFolder
set suffix = getSuffix(aNarration)
if suffix = ".AIF" then sound playFile 1,the pathName & soundFolder & aNarration
else puppetSound aNarration
waitsound 1
end
on getSuffix aString
set r = char (the number of chars in aString - 3) to (the number of chars i